package com.cloud.demo2020;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HystrixClientController {

    @Autowired
    private HystrixService hystrixService;

    @Autowired
    private CodeService codeService;

    private Logger log = LoggerFactory.getLogger(getClass());

    @RequestMapping("/client/infoOk")
    public String infoOk() {
        log.info("ok");
        return hystrixService.infoOk();
    }

    @RequestMapping("/client/infoOk2")
    public String infoOk2() {
        log.info("ok2");
        return hystrixService.infoOk2();
    }

    @RequestMapping("/code/valid/{email}/{code}")
    public Object valid(@PathVariable String email, @PathVariable String code) {
        return codeService.valid(email, code);
    }

}
